package com.simple.accounting.db;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.simple.accounting.R;

public class UserDBManager {
    private static SQLiteDatabase db;

    /*初始化数据库对象*/
    public static void initDB(Context context){
        UserDBHelper helper = new UserDBHelper(context);  //得到帮助类对象
        db = helper.getWritableDatabase();      //得到数据库对象
    }


    public static long insertItemToUserTB(UserInfoBean bean){
        ContentValues values = new ContentValues();
        values.put("username",bean.getUsername());
        values.put("password",bean.getPassword());
        long userinfo = db.insert("userinfo", null, values);
        return userinfo;
    }

    public static int updatePwdToUserTB(UserInfoBean bean){
        ContentValues contentValues = new ContentValues();
        contentValues.put("password",bean.getPassword());
        String[] args = {String.valueOf(bean.username)};
        int i = db.update("userinfo", contentValues,"username = ?" , args);
        return i;
    }

}
